package com.zhanghp.class05;

import com.zhanghp.refer.TreeNode;

/**
 * <h1>二叉树最大深度</h1>
 * <a href = "https://leetcode.cn/problems/maximum-depth-of-binary-tree">leetcode</a>
 *
 * @author zhanghp
 * @since 2024/1/9 14:03
 */
public class Code04_MaximumDepthOfBinaryTree {
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
